﻿package UIComponents// ActionScript file
{
	import flash.display.MovieClip;
	import flash.display.Sprite;
	import flash.text.TextField;

	public class ZombieHotShowPanel extends Sprite
	{
		public var lifeBar:MovieClip;
		public var lifeTxt:TextField;
		public var sxTxt:TextField;
		public var bg:Sprite;
		public function ZombieHotShowPanel():void
		{
			lifeBar=this.getChildByName("bar_life") as MovieClip;
			lifeTxt=this.getChildByName("txt_life") as TextField;
			bg=this.getChildByName("bg") as Sprite;
//			sxTxt=this.getChildByName("") as TextField
			
//			this.showZombieName("dddd僵尸","\n<font color='#FFFFFF' size='24' align='left'>侵蚀:<font color='#FFFFFF'>普通</font>,闪电:<font color='#FF0000'>弱弱</font>\n火焰:<font color='#00FF00'>抗力</font>,物理:<font color='#00FF00'>普通</font></font>");
//			this.showZomBieName("XXXJS","DK DKJ DKFJ KDJF KDJF KDJF KDJF KJDF KDJF KJDF KJ ");
		}
		
		public function showZombieName(value:String,sxTxt:String="",sxTxtCount:uint=0):void			//sxTxt  属性
		{
			if(sxTxtCount!=0){
				
				if(sxTxtCount>2){
					
					bg.height+=60;
					(this.getChildByName("txt_zombieName") as TextField).wordWrap=true;
					
					(this.getChildByName("txt_zombieName") as TextField).maxChars=100;
					(this.getChildByName("txt_zombieName") as TextField).height=120;
					(this.getChildByName("txt_zombieName") as TextField).width=260;
					(this.getChildByName("txt_zombieName") as TextField).htmlText=value;
					(this.getChildByName("txt_zombieName") as TextField).htmlText+=sxTxt;
					
					bg.y-=(80);
					bg.width+=80;
					
					(this.getChildByName("txt_zombieName") as TextField).y=bg.y+10;
					//(this.getChildByName("txt_zombieName") as TextField).x=0;//bg.width/2;
					this.lifeBar.y	-= 20;
					this.lifeTxt.y	-= 20;
					
					this.lifeBar.x	+=40;
					this.lifeTxt.x	+=40;
					
					this.y-=100;
				}
				else{
					bg.height+=30;
					(this.getChildByName("txt_zombieName") as TextField).wordWrap=true;
					
					(this.getChildByName("txt_zombieName") as TextField).maxChars=100;
					(this.getChildByName("txt_zombieName") as TextField).height=60;
					(this.getChildByName("txt_zombieName") as TextField).width=240;
					(this.getChildByName("txt_zombieName") as TextField).htmlText=value;
					(this.getChildByName("txt_zombieName") as TextField).htmlText+=sxTxt;
					
					bg.y-=(40);
					bg.width+=80;
					
					(this.getChildByName("txt_zombieName") as TextField).y=bg.y+10;
					//(this.getChildByName("txt_zombieName") as TextField).x=0;//bg.width/2;
					this.lifeBar.y	-= 20;
					this.lifeTxt.y	-= 20;
					
					this.lifeBar.x	+=40;
					this.lifeTxt.x	+=40;
					
					this.y-=50;
				}
				
			}
			else{
				(this.getChildByName("txt_zombieName") as TextField).text=value;
//				bg.width	=	(this.getChildByName("txt_zombieName") as TextField).width;
			}
			
		}
		
		public function setLife(nowLife:int,maxLife:int):void
		{
			lifeTxt.text=nowLife+"/"+maxLife;
			this.setLifePercent(int(100*nowLife/maxLife));
		}
		
		private function setLifePercent(value:int):void
		{
			this.lifeBar.gotoAndStop(value);
		}
		
		public function release():void
		{
			
		}
	}
}